<a class="" href="/backend/user/role/">Вернуться к списку ролей</a><br/><br/>

<div class="clearfix" style="width: 100%">
	
	<div style="float:left;width: 50%;">
	<h4>Разрешенные ресурсы для роли <b><?=$this->role['label']?></b></h4>
	<ul id="allowed" class="sortme  ui-corner-all" >
		<?php foreach ($this->resources as $res):?>
			<? if(in_array($res['id'],$this->res)):?>
				<li id="<?=$res['id']?>" class='ui-state-default ui-corner-all'><?=$res['label'];?></li>
			<?php endif;?>
		<?php endforeach;?>
	</ul>
	</div>
	<div style="float:left;width: 50%;" >
	<h4>Доступные ресурсы</h4>
		<ul id="resources" class="sortme  ui-corner-all">
		<?php foreach ($this->resources as $res):?>
			<? if(!in_array($res['id'],$this->res)):?>
				<li id="<?=$res['id']?>" class='ui-state-default ui-corner-all'><?=$res['label'];?></li>
			<?php endif;?>
		<?php endforeach;?>
		</ul>
	</div>
</div>









<style>
	#resources, #allowed { list-style-type: none; margin: 0; padding: 0; ;padding:20px;display:block;width:60%;}
	#allowed{ border:solid 1px green !important;}
    #resources{ border:solid 1px red !important;}
	#resources li, #allowed li { margin: 0; padding: 5px;  width: 95%;margin-bottom: 10px; cursor:move;}
	#resources .ui-state-highlight, #allowed .ui-state-highlight { margin: 0; padding: 5px;padding-top:20px;  width: 95%;margin-bottom: 10px;}
</style>
<script type="text/javascript">
	$(function() {
		$( "#resources").sortable({
			connectWith: "#allowed",
			placeholder: "ui-state-highlight",
			remove: function(event, ui) {
				$.post('/backend/user/acl/add/',{id:ui.item.attr('id'),'roleid':<?=$this->role['id']?>},
						function(data){
								if(!data.success){
										alert(data);
								}	
						}
			
				);
						
				
			}
		
		}).disableSelection();
		
		$( "#allowed").sortable({
			connectWith: "#resources",
			placeholder: "ui-state-highlight",
			remove: function(event, ui) {
				$.post('/backend/user/acl/remove/',{id:ui.item.attr('id'),'roleid':<?=$this->role['id']?>},
						function(data){
								if(!data.success){
										alert(data);
								}	
						}
			
				);
			}
		}).disableSelection();
	});
</script>
